/**************************************************************************(C)*
 *
 *  This file is part of the GreenHills project
 *  Copyright (C) 2009  Tieto Corporation
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  Not for commmercial use. Only with Tieto permission.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *************************************************************************(C)*/

#pragma once


#include <QtGui/QPainter>
#include <QtGui/QWidget>

namespace greenhills {
namespace client {
/**
 * @brief Compas widget showing walking direction and direction to target.
 *
 */
class CCompas : public QWidget
{
    Q_OBJECT

public:
/**
 *@brief Initializes the class variables mDirectionToTarget and mDirection to value 0
 *
 *
 */
    CCompas(QWidget *pParent = 0);

    virtual ~CCompas(){}


private:

         QPoint mHand[4];


      QPoint mRose[3];

   /**
    *@brief direction to the target showed in compass by hand
    *
    */
    int mDirectionToTarget;

   /**
    *@brief direction of the player showed in compass by compass rose
    *
    */
    int mDirection;


    /**
    *@brief this variables are used to set up a parameters for drawing
    *       the appropriate part of compass properlly in participate method
    */

    QConicalGradient mHand_color;

    QConicalGradient mRose_color;

    QRadialGradient mSupport;

    QRadialGradient mEllipse;

    QRadialGradient mBolt;

    QRadialGradient mGlass;

    QRadialGradient mScrew;

    QLinearGradient mBase;

    QFont mText_font;

    QPen mText_pen;

    QPen mThick_pen;

    QPen mRose_pen;

    QPen mThin_pen;

   /**
    *@brief this method is used to redraw the parts of compass that are moved
    */
    void draw(QPainter &pPainter);

    /**
    *@brief draws the base around the compass
    */
    void drawBase(QPainter &pPainter);

    /**
    *@brief draws the glass over the compass face only for decoration
    */
    void drawGlass(QPainter &pPainter);

    /**
    *@brief draws the compass rose whitch can be turning around center of it by slot onDirectionChanged
    */
    void drawCompassRose(QPainter &pPainter);

    /**
    *@brief draws the hand, whitch can be moved by slot onDirectionToTargetChanged
    */
    void drawHand(QPainter &pPainter);
    /**
    *@brief draws the bolt in the center of compass
    */
    void drawBolt(QPainter &pPainter);

   /**
    *@brief inherited from QWidget
    */
    virtual void paintEvent(QPaintEvent *pEvent);

public slots:
  /**
    *@brief slot emited by GPS coordinates that sets variable mDirectionToTarget
    *
    */
     void onDirectionToTargetChanged(int pVal);

   /**
    *@brief @brief slot emited by GPS coordinates that sets variable mDirection
    *
    */
     void onDirectionChanged(int pVal);
 };

} //namespace client
} //namespace greenhills
